<?php

/**
 *      [Discuz!] (C)2001-2099 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *		has readed
 *      $Id: search.php 34131 2013-10-17 03:54:09Z andyzheng $
 */

define('APPTYPEID', 0);
define('CURSCRIPT', 'search');

require './source/class/class_core.php';

$discuz = C::app();

$modarray = array('user', 'curforum', 'newthread', );

$cachelist = $slist = array();
$mod = '';

$discuz->cachelist = $cachelist;
$discuz->init();

if(in_array($discuz->var['mod'], $modarray) || !empty($_G['setting']['search'][$discuz->var['mod']]['status'])) {
	$mod = $discuz->var['mod'];//全局-搜索设置-开启了对应模块

} else {
	foreach($_G['setting']['search'] as $mod => $value) {//选一个可以搜索的模块
		if(!empty($value['status'])) {
			break;
		}
	}

}
if(empty($mod)) {
	showmessage('search_closed');
}
define('CURMODULE', $mod);
loadcache('creditrule');//修改2
if(!($_G['group']['exempt'] & 2) && is_array($_G['cache']['creditrule']['search'])) {
	$data = [];
	$creditrule = $_G['cache']['creditrule']['search'];
	for($i = 1; $i <= 8; $i++) {
		if($creditrule['extcredits'.$i]) {
			$data[$i] = $creditrule['extcredits'.$i];
		}
	}
	$_G['setting']['creditspolicy']['search'] = $data;
}
//var_dump($_G['setting']['creditspolicy']);exit(1);
//修改3 $policymsgs 修改4 seltableid
runhooks();

if (!$_G['setting'][($mod == 'curforum' ? 'forum' : ($mod == 'user' ? 'friend' : $mod)).'status']) {
	showmessage(($mod == 'curforum' ? 'forum' : ($mod == 'user' ? 'friend' : ($mod == 'group' ? 'group_module' : $mod))).'_status_off');
}

require_once libfile('function/search');


$navtitle = lang('core', 'title_search');

if($mod == 'curforum') {
	$mod = 'forum';
	$_GET['srchfid'] = array($_GET['srhfid']);
} elseif($mod == 'forum') {
	$_GET['srhfid'] = 0;
}

require DISCUZ_ROOT.'./source/module/search/search_'.$mod.'.php';

?>